package fun.xinnix.service.impl;

import fun.xinnix.entity.User;
import fun.xinnix.entity.dto.KafkaMessageDto;
import fun.xinnix.service.KafkaService;
import fun.xinnix.utils.KafkaUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.kafka.support.SendResult;
import org.springframework.stereotype.Service;
import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.util.concurrent.ListenableFutureCallback;

import javax.annotation.Resource;

@Slf4j
@Service
public class KafkaServiceImpl implements KafkaService {
    @Resource
    private KafkaUtil kafkaUtil;

    /**
     * 发送消息
     *
     * @param dto 主题名 消息体
     */
    @Override
    public void sendMessage(KafkaMessageDto dto) {
        kafkaUtil.sendMessage(dto.getTopicName(), dto.getKey(), dto.getObject());
    }
}
